package Demo;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Test1 {
    public static void main(String[] args) {
        //创建一个默认的线程池,默认最多容纳int类型最大值
        ExecutorService executorService = Executors.newCachedThreadPool();
        //Executors 帮我们创建线程池对象
        //ExecutorService  帮我们控制线程池

        //submit()提交
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"1号执行");
        });

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"2号执行");
        });
        //直接结束
        executorService.shutdown();

    }
}
